<?php

declare(strict_types=1);

namespace app\model\system;

use owns\interface\OwnsModelInteface;

class LoggerOperModel extends OwnsModelInteface
{
    protected $name = 'system_logger_oper';

    protected $field = [];

    /**
     * 查询条件
     * @param object $query
     * @param array $param
     */
    public function scopeCustom(object $query, array $param)
    {
        //账户
        if ($username = $param['username'] ?? '') {
            $query->whereLike('username', '%' . trim($username) . '%');
        }
        //地址ip
        if ($ip = $param['ip'] ?? '') {
            $query->whereLike('ip', '%' . trim($ip) . '%');
        }
    }
}
